<?php
/*
 * @Author: 李明
 * @Date: 2021-10-28 11:51:29
 * @LastEditTime: 2021-11-30 18:06:03
 * @LastEditors: 李明
 * @Description: 
 * @FilePath: /CRM2.0-PHP/app/Models/OaFlow.php
 * @山东壹零贰肆信息科技有限公司
 */

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

/**
 * Class OaFlow
 * 
 * @property int $id
 * @property int|null $p_id
 * @property int|null $worker_id
 * @property int|null $oa_model_id
 * @property string|null $level
 * @property string|null $type
 * @property string|null $worker_type
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 * 
 * @property OaFlow|null $oa_flow
 * @property OaModel|null $oa_model
 * @property Worker|null $worker
 * @property Collection|OaFlow[] $oa_flows
 * @property Collection|OaRecord[] $oa_records
 *
 * @package App\Models
 */
class OaFlow extends Model
{
    protected $table = 'oa_flow';

    protected $casts = [
        'p_id' => 'int',
        'worker_id' => 'int',
        'oa_model_id' => 'int'
    ];

    protected $fillable = [
        'p_id',
        'worker_id',
        'oa_model_id',
        'level',
        'type',
        'worker_type'
    ];

    public function oa_flow()
    {
        return $this->belongsTo(OaFlow::class, 'p_id');
    }

    public function oa_model()
    {
        return $this->belongsTo(OaModel::class);
    }

    public function worker()
    {
        return $this->belongsTo(Worker::class);
    }

    public function oa_flows()
    {
        return $this->hasMany(OaFlow::class, 'p_id');
    }

    public function oa_records()
    {
        return $this->hasMany(OaRecord::class);
    }
}
